package donjuan;

import java.awt.CardLayout;
import java.sql.Statement;
import java.util.ArrayList;
import javax.swing.JPanel;
//此面板采用cardlayout布局，将其他面板汇总于此，是一个面板的集合
class Window_main extends JPanel {
  ArrayList<Readin> cha = null;
  
  Statement sql = null;
  
  public static int mode = 0;
  
  public static JPanel p1 = new JPanel();
  
  static CardLayout poker = new CardLayout();
  
  public Window_Login log = new Window_Login();
  
  static Window_ready ready = new Window_ready();
  
  Window_present present = new Window_present();
  
  Window_manage man = new Window_manage();
  
  Window_main(ArrayList<Readin> cha, Statement sql) {
    this.cha = cha;
    this.sql = sql;
    setVisible(true);
    setBounds(10, 10, 500, 500);
    init();
  }
  
  void init() {
    p1.setLayout(poker);
    p1.setBounds(10, 10, 500, 500);
    p1.add("manage", this.man);
    p1.add("login", this.log);
    p1.add("ready", ready);
    p1.add("present", this.present);
    poker.first(p1);
  }
  
  static void jump() {//每当触发该方法，就会实现不同窗口的展示
    if (mode == 1 || mode == 4) {
      poker.show(p1, "ready");
      ready.changemode(mode);
    } else if (mode == 2) {
      if (!Message.Link_start.booleanValue())
        Message.registersql(); 
      Message.Link_start = Boolean.valueOf(true);
      poker.show(p1, "present");
    } else if (mode == 3) {
      poker.show(p1, "ready");
    } else if (mode == 5)
    {
      if (!Message.Link_start) 
      {
        Message.registersql();
        Message.activatesql();
      } 
      Message.Link_start = Boolean.valueOf(true);
      poker.show(p1, "login");
    } 
    else if (mode == 6) {
      poker.show(p1, "manage");
    } 
  }
}
